package org.jasper.impl.utils;

import org.jasper.api.container.Message;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by OP038074 on 2018/8/1.
 */
public class MessageImpl {
    public static List<Message> filterMessages( List<Message> messages,
                                                Message.Level... levels ) {
        List<Message> filteredMsgs = new ArrayList<Message>();
        if ( levels != null && levels.length > 0 ) {
            for ( Message.Level level : levels ) {
                for ( Message msg : messages ) {
                    if ( msg.getLevel() == level ) {
                        filteredMsgs.add( msg );
                    }
                }
            }
        }
        return filteredMsgs;
    }
}
